<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">发送语音短信</ui:define>
    <ui:define name="content">
        <h:form>

            <p:dialog id="transferLinkDialog" rendered="#{sendVoiceSmsBean.$.status.ordinal() == 5}"
                      header="源链接转短链接" position="center" widgetVar="transferLinkDialogWidgeVar" modal="true" width="750"
                      height="230" responsive="true" resizable="false">
                <p:panelGrid columns="2"
                             columnClasses="ui-grid-col-3,ui-grid-col-9"
                             layout="grid" styleClass="ui-panelgrid-blank"
                             style="border:0px none; background-color:transparent;">

                    <p:outputLabel for="linkType" value="链接类型"/>
                    <p:selectOneMenu id="linkType" value="#{sendVoiceSmsBean.$.linkType}">
                        <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                        <f:selectItem itemLabel="菠萝贷链接" itemValue="1" noSelectionOption="true"/>
                        <f:selectItem itemLabel="第三方链接" itemValue="2" noSelectionOption="true"/>
                    </p:selectOneMenu>

                    <p:outputLabel for="environment" value="作用环境"/>
                    <p:selectOneMenu id="environment" value="#{sendVoiceSmsBean.shortLinkEntity.environment}">
                        <f:selectItem itemLabel="- 请选择 -" itemValue="" noSelectionOption="true"/>
                        <f:selectItem itemLabel="app内部" itemValue="1" noSelectionOption="true"/>
                        <f:selectItem itemLabel="app外部" itemValue="0" noSelectionOption="true"/>
                    </p:selectOneMenu>

                    <p:outputLabel for="originalLink" value="源链接"/>
                    <p:inputText id="originalLink" value="#{sendVoiceSmsBean.shortLinkEntity.url}" style="width:100%"/>

                    <p:outputLabel for="activity" value="项目"/>
                    <p:inputText id="activity" value="#{sendVoiceSmsBean.shortLinkEntity.activity}" style="width:100%"/>

                    <p:outputLabel for="memo" value="备注"/>
                    <p:inputText id="memo" value="#{sendVoiceSmsBean.shortLinkEntity.memo}" style="width:100%"/>

                </p:panelGrid>
                <div style="text-align:right;padding-top:20px">
                    <p:commandButton value="确定" actionListener="#{sendVoiceSmsBean.onTransferLink(sendVoiceSmsBean.$.id)}"
                                     process="transferLinkDialog" update="@form" oncomplete="PF('shortLinkDialogWidgeVar').show()"/>
                </div>
            </p:dialog>

            <p:dialog id="shortLinkDialog" rendered="#{sendVoiceSmsBean.shortLink != null}"
                      header="短链接" position="center" widgetVar="shortLinkDialogWidgeVar" modal="true" width="650"
                      height="100" responsive="true">
                <p:panelGrid columns="2"
                             columnClasses="ui-grid-col-3,ui-grid-col-9"
                             layout="grid" styleClass="ui-panelgrid-blank"
                             style="border:0px none; background-color:transparent;">

                    <p:outputLabel for="shortLink" value="短链接"/>
                    <p:inputText id="shortLink" value="#{sendVoiceSmsBean.shortLink}" style="width:100%"/>

                </p:panelGrid>
                <div style="text-align:right;padding-top:20px">
                    <p:commandButton value="确定"
                                     process="shortLinkDialog" update="@form" />
                </div>
            </p:dialog>

            <div class="topbar clearfix"
                 style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar id="buttonToolBar">
                    <f:facet name="right">
                        <p:commandButton
                                icon="fa fa-bullhorn"
                                value="链接转换"
                                update="@form"
                                rendered="#{sendVoiceSmsBean.$.status.ordinal() == 5}"
                                oncomplete="PF('transferLinkDialogWidgeVar').show()">
                        </p:commandButton>
                        <p:commandButton
                                actionListener="#{sendVoiceSmsBean.onSend}"
                                icon="fa fa-bullhorn"
                                value="发送"
                                update="@form"
                                rendered="#{sendVoiceSmsBean.$.status.ordinal() == 5}">
                            <p:confirm header="提示信息" message="确定发送?" icon="ui-icon-alert"/>
                        </p:commandButton>
                        <p:button value="返回" icon="fa fa-reply-all"
                                  outcome="/views/family/user-info/send-sms/calculate-sms.xhtml"/>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">
                        <div class="card ui-g-12">
                            <div class="ui-g-1">
                                <p:outputLabel value="短信平台"/>
                                <strong style="color: red">*</strong>
                            </div>
                            <div class="ui-g-5">
                                <p:selectOneMenu id="platformChannel" value="#{sendVoiceSmsBean.$.platformChannel}">
                                    <p:ajax event="change" process="@this" update=""/>
                                    <f:selectItems
                                            value="#{sendVoiceSmsBean.dictionaries[DictionaryCode.SMS_VOICE_PLATFORM_CHANNEL]}"
                                            var="dic"
                                            itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                                </p:selectOneMenu>
                            </div>

                            <div class="ui-g-2">
                                <p:outputLabel value="计划发送时间"/>
                            </div>
                            <div class="ui-g-4">
                                <p:calendar value="#{sendVoiceSmsBean.$.executeTime}"
                                            locale="#{constants:get('LOCALE')}"
                                            timeZone="#{constants:get('TIME_ZONE')}"
                                            pattern="#{constants:get('DATETIME_FORMAT')}"
                                            readonlyInput="true"/>
                            </div>
                        </div>
                    </div>
                    
                    <div class="ui-g-12">
                        <div class="card ui-g-12">
                            <div class="ui-g-12">
                                <h3><b>短信内容</b></h3>
                            </div>

                            <div class="ui-g-1">
                                <p:outputLabel value="甲方名称"/>
                                 <strong style="color: red">*</strong>
                            </div>
                            <div class="ui-g-5">
                                <p:inputText value="#{sendVoiceSmsBean.$.firstPartyName}">
                                </p:inputText>
                            </div>

                            <div class="ui-g-1">
                                <p:outputLabel value="语音模板"/>
                                <strong style="color: red">*</strong>
                            </div>
                            <div class="ui-g-5">
                                <p:selectOneMenu id="voiceId" value="#{sendVoiceSmsBean.$.voiceId}">
                                    <f:selectItems
                                            value="#{sendVoiceSmsBean.dictionaries[DictionaryCode.SMS_VOICE_ID]}"
                                            var="dic"
                                            itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                                </p:selectOneMenu>
                            </div>
                            
                        </div>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>